{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Regressão Linear Multivariada - Trabalho\n",
    "\n",
    "## Estudo de caso: Qualidade de Vinhos\n",
    "\n",
    "Nesta trabalho, treinaremos um modelo de regressão linear usando descendência de gradiente estocástico no conjunto de dados da Qualidade do Vinho. O exemplo pressupõe que uma cópia CSV do conjunto de dados está no diretório de trabalho atual com o nome do arquivo *winequality-white.csv*.\n",
    "\n",
    "O conjunto de dados de qualidade do vinho envolve a previsão da qualidade dos vinhos brancos em uma escala, com medidas químicas de cada vinho. É um problema de classificação multiclasse, mas também pode ser enquadrado como um problema de regressão. O número de observações para cada classe não é equilibrado. Existem 4.898 observações com 11 variáveis de entrada e 1 variável de saída. Os nomes das variáveis são os seguintes:\n",
    "\n",
    "1. Fixed acidity.\n",
    "2. Volatile acidity.\n",
    "3. Citric acid.\n",
    "4. Residual sugar.\n",
    "5. Chlorides.\n",
    "6. Free sulfur dioxide. \n",
    "7. Total sulfur dioxide. \n",
    "8. Density.\n",
    "9. pH.\n",
    "10. Sulphates.\n",
    "11. Alcohol.\n",
    "12. Quality (score between 0 and 10).\n",
    "\n",
    "O desempenho de referencia de predição do valor médio é um RMSE de aproximadamente 0.148 pontos de qualidade.\n",
    "\n",
    "Utilize o exemplo apresentado no tutorial e altere-o de forma a carregar os dados e analisar a acurácia de sua solução. \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 154,
   "metadata": {},
   "outputs": [],
   "source": [
    "import csv\n",
    "import random\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn import preprocessing\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "def coefficients_sgd(train, l_rate, n_epoch):\n",
    "    size = train.shape[0]\n",
    "    coef = np.random.normal(size=train.shape[1]-1)\n",
    "    print ('Coeficiente Inicial=',(coef))\n",
    "    errors = []\n",
    "    \n",
    "    for epoch in range(n_epoch):\n",
    "        sum_error = 0\n",
    "        for row in train.values:\n",
    "            x = row[0:-1]\n",
    "            yhat = np.dot(x, coef)\n",
    "            error = yhat - row[-1]\n",
    "            sum_error += error**2\n",
    "            coef = coef - l_rate * error * x\n",
    "        rmse = np.sqrt(sum_error/size) \n",
    "        errors.append(rmse)\n",
    "        print(('epoch=%d, lrate=%.3f, RMSE=%.3f' % (epoch, l_rate, rmse)))\n",
    "    return coef, errors\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(4898, 13)\n"
     ]
    }
   ],
   "source": [
    "dataset = pd.read_csv('winequality-white.csv', delimiter=\";\")\n",
    "\n",
    "cols = list(dataset.columns)\n",
    "cols.remove('quality')\n",
    "\n",
    "datasetNorm = pd.DataFrame(preprocessing.scale(dataset[cols]))\n",
    "datasetNorm['y'] = dataset['quality']\n",
    "\n",
    "idx = 0\n",
    "new_col = np.ones(datasetNorm.shape[0])  # can be a list, a Series, an array or a scalar   \n",
    "datasetNorm.insert(loc=idx, column='B0', value=new_col)\n",
    "\n",
    "print(datasetNorm.shape)\n",
    "\n",
    "train, test = train_test_split(datasetNorm, test_size=0.3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Coeficiente Inicial= [-0.45111468  2.23254304 -1.48777801  0.262857   -0.35499591 -0.03776972\n",
      "  1.26994076 -1.44760054 -0.02891993 -0.30925472 -0.28220391  1.83270609]\n",
      "epoch=0, lrate=0.000, RMSE=7.146\n",
      "epoch=1, lrate=0.000, RMSE=6.884\n",
      "epoch=2, lrate=0.000, RMSE=6.635\n",
      "epoch=3, lrate=0.000, RMSE=6.398\n",
      "epoch=4, lrate=0.000, RMSE=6.171\n",
      "epoch=5, lrate=0.000, RMSE=5.954\n",
      "epoch=6, lrate=0.000, RMSE=5.747\n",
      "epoch=7, lrate=0.000, RMSE=5.549\n",
      "epoch=8, lrate=0.000, RMSE=5.359\n",
      "epoch=9, lrate=0.000, RMSE=5.177\n",
      "epoch=10, lrate=0.000, RMSE=5.002\n",
      "epoch=11, lrate=0.000, RMSE=4.835\n",
      "epoch=12, lrate=0.000, RMSE=4.674\n",
      "epoch=13, lrate=0.000, RMSE=4.520\n",
      "epoch=14, lrate=0.000, RMSE=4.371\n",
      "epoch=15, lrate=0.000, RMSE=4.229\n",
      "epoch=16, lrate=0.000, RMSE=4.092\n",
      "epoch=17, lrate=0.000, RMSE=3.961\n",
      "epoch=18, lrate=0.000, RMSE=3.835\n",
      "epoch=19, lrate=0.000, RMSE=3.713\n",
      "epoch=20, lrate=0.000, RMSE=3.597\n",
      "epoch=21, lrate=0.000, RMSE=3.484\n",
      "epoch=22, lrate=0.000, RMSE=3.376\n",
      "epoch=23, lrate=0.000, RMSE=3.273\n",
      "epoch=24, lrate=0.000, RMSE=3.173\n",
      "epoch=25, lrate=0.000, RMSE=3.077\n",
      "epoch=26, lrate=0.000, RMSE=2.985\n",
      "epoch=27, lrate=0.000, RMSE=2.896\n",
      "epoch=28, lrate=0.000, RMSE=2.811\n",
      "epoch=29, lrate=0.000, RMSE=2.729\n",
      "epoch=30, lrate=0.000, RMSE=2.651\n",
      "epoch=31, lrate=0.000, RMSE=2.575\n",
      "epoch=32, lrate=0.000, RMSE=2.502\n",
      "epoch=33, lrate=0.000, RMSE=2.432\n",
      "epoch=34, lrate=0.000, RMSE=2.365\n",
      "epoch=35, lrate=0.000, RMSE=2.301\n",
      "epoch=36, lrate=0.000, RMSE=2.239\n",
      "epoch=37, lrate=0.000, RMSE=2.179\n",
      "epoch=38, lrate=0.000, RMSE=2.122\n",
      "epoch=39, lrate=0.000, RMSE=2.067\n",
      "epoch=40, lrate=0.000, RMSE=2.014\n",
      "epoch=41, lrate=0.000, RMSE=1.964\n",
      "epoch=42, lrate=0.000, RMSE=1.915\n",
      "epoch=43, lrate=0.000, RMSE=1.868\n",
      "epoch=44, lrate=0.000, RMSE=1.824\n",
      "epoch=45, lrate=0.000, RMSE=1.781\n",
      "epoch=46, lrate=0.000, RMSE=1.739\n",
      "epoch=47, lrate=0.000, RMSE=1.700\n",
      "epoch=48, lrate=0.000, RMSE=1.662\n",
      "epoch=49, lrate=0.000, RMSE=1.626\n",
      "epoch=50, lrate=0.000, RMSE=1.591\n",
      "epoch=51, lrate=0.000, RMSE=1.558\n",
      "epoch=52, lrate=0.000, RMSE=1.526\n",
      "epoch=53, lrate=0.000, RMSE=1.495\n",
      "epoch=54, lrate=0.000, RMSE=1.466\n",
      "epoch=55, lrate=0.000, RMSE=1.438\n",
      "epoch=56, lrate=0.000, RMSE=1.411\n",
      "epoch=57, lrate=0.000, RMSE=1.385\n",
      "epoch=58, lrate=0.000, RMSE=1.360\n",
      "epoch=59, lrate=0.000, RMSE=1.337\n",
      "epoch=60, lrate=0.000, RMSE=1.314\n",
      "epoch=61, lrate=0.000, RMSE=1.293\n",
      "epoch=62, lrate=0.000, RMSE=1.272\n",
      "epoch=63, lrate=0.000, RMSE=1.252\n",
      "epoch=64, lrate=0.000, RMSE=1.233\n",
      "epoch=65, lrate=0.000, RMSE=1.215\n",
      "epoch=66, lrate=0.000, RMSE=1.198\n",
      "epoch=67, lrate=0.000, RMSE=1.181\n",
      "epoch=68, lrate=0.000, RMSE=1.165\n",
      "epoch=69, lrate=0.000, RMSE=1.150\n",
      "epoch=70, lrate=0.000, RMSE=1.136\n",
      "epoch=71, lrate=0.000, RMSE=1.122\n",
      "epoch=72, lrate=0.000, RMSE=1.109\n",
      "epoch=73, lrate=0.000, RMSE=1.096\n",
      "epoch=74, lrate=0.000, RMSE=1.084\n",
      "epoch=75, lrate=0.000, RMSE=1.072\n",
      "epoch=76, lrate=0.000, RMSE=1.061\n",
      "epoch=77, lrate=0.000, RMSE=1.051\n",
      "epoch=78, lrate=0.000, RMSE=1.040\n",
      "epoch=79, lrate=0.000, RMSE=1.031\n",
      "epoch=80, lrate=0.000, RMSE=1.021\n",
      "epoch=81, lrate=0.000, RMSE=1.013\n",
      "epoch=82, lrate=0.000, RMSE=1.004\n",
      "epoch=83, lrate=0.000, RMSE=0.996\n",
      "epoch=84, lrate=0.000, RMSE=0.988\n",
      "epoch=85, lrate=0.000, RMSE=0.981\n",
      "epoch=86, lrate=0.000, RMSE=0.974\n",
      "epoch=87, lrate=0.000, RMSE=0.967\n",
      "epoch=88, lrate=0.000, RMSE=0.960\n",
      "epoch=89, lrate=0.000, RMSE=0.954\n",
      "epoch=90, lrate=0.000, RMSE=0.948\n",
      "epoch=91, lrate=0.000, RMSE=0.942\n",
      "epoch=92, lrate=0.000, RMSE=0.936\n",
      "epoch=93, lrate=0.000, RMSE=0.931\n",
      "epoch=94, lrate=0.000, RMSE=0.926\n",
      "epoch=95, lrate=0.000, RMSE=0.921\n",
      "epoch=96, lrate=0.000, RMSE=0.916\n",
      "epoch=97, lrate=0.000, RMSE=0.912\n",
      "epoch=98, lrate=0.000, RMSE=0.907\n",
      "epoch=99, lrate=0.000, RMSE=0.903\n",
      "epoch=100, lrate=0.000, RMSE=0.899\n",
      "epoch=101, lrate=0.000, RMSE=0.895\n",
      "epoch=102, lrate=0.000, RMSE=0.892\n",
      "epoch=103, lrate=0.000, RMSE=0.888\n",
      "epoch=104, lrate=0.000, RMSE=0.885\n",
      "epoch=105, lrate=0.000, RMSE=0.881\n",
      "epoch=106, lrate=0.000, RMSE=0.878\n",
      "epoch=107, lrate=0.000, RMSE=0.875\n",
      "epoch=108, lrate=0.000, RMSE=0.872\n",
      "epoch=109, lrate=0.000, RMSE=0.869\n",
      "epoch=110, lrate=0.000, RMSE=0.866\n",
      "epoch=111, lrate=0.000, RMSE=0.864\n",
      "epoch=112, lrate=0.000, RMSE=0.861\n",
      "epoch=113, lrate=0.000, RMSE=0.859\n",
      "epoch=114, lrate=0.000, RMSE=0.856\n",
      "epoch=115, lrate=0.000, RMSE=0.854\n",
      "epoch=116, lrate=0.000, RMSE=0.852\n",
      "epoch=117, lrate=0.000, RMSE=0.849\n",
      "epoch=118, lrate=0.000, RMSE=0.847\n",
      "epoch=119, lrate=0.000, RMSE=0.845\n",
      "epoch=120, lrate=0.000, RMSE=0.843\n",
      "epoch=121, lrate=0.000, RMSE=0.841\n",
      "epoch=122, lrate=0.000, RMSE=0.839\n",
      "epoch=123, lrate=0.000, RMSE=0.838\n",
      "epoch=124, lrate=0.000, RMSE=0.836\n",
      "epoch=125, lrate=0.000, RMSE=0.834\n",
      "epoch=126, lrate=0.000, RMSE=0.833\n",
      "epoch=127, lrate=0.000, RMSE=0.831\n",
      "epoch=128, lrate=0.000, RMSE=0.829\n",
      "epoch=129, lrate=0.000, RMSE=0.828\n",
      "epoch=130, lrate=0.000, RMSE=0.826\n",
      "epoch=131, lrate=0.000, RMSE=0.825\n",
      "epoch=132, lrate=0.000, RMSE=0.824\n",
      "epoch=133, lrate=0.000, RMSE=0.822\n",
      "epoch=134, lrate=0.000, RMSE=0.821\n",
      "epoch=135, lrate=0.000, RMSE=0.820\n",
      "epoch=136, lrate=0.000, RMSE=0.819\n",
      "epoch=137, lrate=0.000, RMSE=0.817\n",
      "epoch=138, lrate=0.000, RMSE=0.816\n",
      "epoch=139, lrate=0.000, RMSE=0.815\n",
      "epoch=140, lrate=0.000, RMSE=0.814\n",
      "epoch=141, lrate=0.000, RMSE=0.813\n",
      "epoch=142, lrate=0.000, RMSE=0.812\n",
      "epoch=143, lrate=0.000, RMSE=0.811\n",
      "epoch=144, lrate=0.000, RMSE=0.810\n",
      "epoch=145, lrate=0.000, RMSE=0.809\n",
      "epoch=146, lrate=0.000, RMSE=0.808\n",
      "epoch=147, lrate=0.000, RMSE=0.807\n",
      "epoch=148, lrate=0.000, RMSE=0.806\n",
      "epoch=149, lrate=0.000, RMSE=0.805\n",
      "epoch=150, lrate=0.000, RMSE=0.805\n",
      "epoch=151, lrate=0.000, RMSE=0.804\n",
      "epoch=152, lrate=0.000, RMSE=0.803\n",
      "epoch=153, lrate=0.000, RMSE=0.802\n",
      "epoch=154, lrate=0.000, RMSE=0.801\n",
      "epoch=155, lrate=0.000, RMSE=0.801\n",
      "epoch=156, lrate=0.000, RMSE=0.800\n",
      "epoch=157, lrate=0.000, RMSE=0.799\n",
      "epoch=158, lrate=0.000, RMSE=0.798\n",
      "epoch=159, lrate=0.000, RMSE=0.798\n",
      "epoch=160, lrate=0.000, RMSE=0.797\n",
      "epoch=161, lrate=0.000, RMSE=0.797\n",
      "epoch=162, lrate=0.000, RMSE=0.796\n",
      "epoch=163, lrate=0.000, RMSE=0.795\n",
      "epoch=164, lrate=0.000, RMSE=0.795\n",
      "epoch=165, lrate=0.000, RMSE=0.794\n",
      "epoch=166, lrate=0.000, RMSE=0.794\n",
      "epoch=167, lrate=0.000, RMSE=0.793\n",
      "epoch=168, lrate=0.000, RMSE=0.792\n",
      "epoch=169, lrate=0.000, RMSE=0.792\n",
      "epoch=170, lrate=0.000, RMSE=0.791\n",
      "epoch=171, lrate=0.000, RMSE=0.791\n",
      "epoch=172, lrate=0.000, RMSE=0.790\n",
      "epoch=173, lrate=0.000, RMSE=0.790\n",
      "epoch=174, lrate=0.000, RMSE=0.789\n",
      "epoch=175, lrate=0.000, RMSE=0.789\n",
      "epoch=176, lrate=0.000, RMSE=0.789\n",
      "epoch=177, lrate=0.000, RMSE=0.788\n",
      "epoch=178, lrate=0.000, RMSE=0.788\n",
      "epoch=179, lrate=0.000, RMSE=0.787\n",
      "epoch=180, lrate=0.000, RMSE=0.787\n",
      "epoch=181, lrate=0.000, RMSE=0.786\n",
      "epoch=182, lrate=0.000, RMSE=0.786\n",
      "epoch=183, lrate=0.000, RMSE=0.786\n",
      "epoch=184, lrate=0.000, RMSE=0.785\n",
      "epoch=185, lrate=0.000, RMSE=0.785\n",
      "epoch=186, lrate=0.000, RMSE=0.785\n",
      "epoch=187, lrate=0.000, RMSE=0.784\n",
      "epoch=188, lrate=0.000, RMSE=0.784\n",
      "epoch=189, lrate=0.000, RMSE=0.784\n",
      "epoch=190, lrate=0.000, RMSE=0.783\n",
      "epoch=191, lrate=0.000, RMSE=0.783\n",
      "epoch=192, lrate=0.000, RMSE=0.783\n",
      "epoch=193, lrate=0.000, RMSE=0.782\n",
      "epoch=194, lrate=0.000, RMSE=0.782\n",
      "epoch=195, lrate=0.000, RMSE=0.782\n",
      "epoch=196, lrate=0.000, RMSE=0.781\n",
      "epoch=197, lrate=0.000, RMSE=0.781\n",
      "epoch=198, lrate=0.000, RMSE=0.781\n",
      "epoch=199, lrate=0.000, RMSE=0.781\n",
      "Coeficiente Final= [  5.86812920e+00  -4.19244636e-02  -1.86885075e-01  -3.58146598e-02\n",
      "  -1.49440419e-02   2.63705850e-03   2.10170502e-01  -1.78754580e-01\n",
      "   2.65607665e-01   1.08557358e-02   4.20615454e-02   5.98836336e-01]\n"
     ]
    }
   ],
   "source": [
    "# Calculate coefficients\n",
    "l_rate = 1e-5\n",
    "n_epoch = 200\n",
    "coefs, errors = coefficients_sgd(train, l_rate, n_epoch)\n",
    "print('Coeficiente Final=',coefs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAD8CAYAAABXe05zAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAG3xJREFUeJzt3Xl0XOWd5vHvrxZJ1i5ZkjfZlle8gGVjYTbb7GsCpEmT\nQNIJ3cmE6QSYMMOcDBkyk+6eMzkndEO6J5NOmoRMB0IgpNkJaZaw2ARjkPd9X2VbkjdJXiRLqnf+\nqJKRhWVJRlX33qrnc45O3bp1S3rOW+XHt957q8qcc4iISHCEvA4gIiIDo+IWEQkYFbeISMCouEVE\nAkbFLSISMCpuEZGAUXGLiASMiltEJGBU3CIiARNJxi8tKytzVVVVyfjVIiJpacmSJfudc+X92TYp\nxV1VVUVtbW0yfrWISFoysx393VZTJSIiAaPiFhEJGBW3iEjAqLhFRAJGxS0iEjAqbhGRgFFxi4gE\nj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XP1iYy+GDN6\nHx9fPO/M7C+BzwJfTvyDJ/Gy+kBieQnxedHJqcp0hsfO8zEzswhwK/DbrnWpHq/TdQQpfJ75pbg/\nAiaZ2bjEXtvtwEteBEnMnT0GrHPOPdJt/Yhum/0ZsLrnfVOQLc/MCrqWiR/YWk18rO5MbHYn8GKq\nsyWcshfkhzFL6G18XgJuN7NsMxsHTAI+TGUwM7se+A5ws3PuWLf15WYWTiyPT2TbmsJcvT12no8Z\ncDWw3jm3u2tFKsert44glc+zVByF7eeR2huJH53dAjzoYY65xF/irASWJ35uBJ4AViXWvwSM8CDb\neOJHp1cAa7rGCRgK/BHYBLwJlHqQLQ84ABR1W5fyMSP+H8deoJ34XOLXzzQ+wIOJ59wG4AYPsm0m\nPv/Z9Vz7WWLbzyce4+XAUuCmFOfq9bFL1ZidLldi/b8Cf91j21SOV28dkbLnmd45KSISMH6ZKhER\nkX5ScYuIBIyKW0QkYFTcIiIBo+IWEQkYFbeISMCouEVEAkbFLSISMP8fSEUiUUOfw5UAAAAASUVO\nRK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x115098fd0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#Gráfico de Custo por Época\n",
    "plt.plot(errors)\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
